package Arrays;

/**
 * 作者:hfj
 * 功能:278.第一个错误版本
 * 日期: 2025/10/29 8:44
 */
public class FirstBadVersion{

    public int firstBadVersion(int n) {
        int left = 0;
        int right = n;
        while(left<=right){
            int mid = left + (right - left)/2;
            if(isBadVersion(mid) && !isBadVersion(mid-1)){
                return mid;
            }else if(isBadVersion(mid)){
                right = mid - 1;
            }else{
                left = mid + 1;
            }
        }
        return 0;
    }

    private boolean isBadVersion(int mid) {
        return true;
    }
}
